package com.caiyi.tips.core.exception;

import com.caiyi.tips.core.VO.ResultVO;

/*
 * 核心异常类。所有自定义异常继承这个类
 * @author Cliff.ZhouYang
 * @date 2017/11/15 15:21
 */
public abstract class BaseException extends RuntimeException {
    private String code = "0";

    @Deprecated
    public ResultVO getBoltResult() {
        return getResult();
    }

    public ResultVO getResult() {
        return ResultVO.fail(code, this.getMessage() != null ? this.getMessage() : "出错");
    }

    public BaseException() {
        code = "9999";
    }

    public BaseException(String message) {
        super(message);
    }

    public BaseException(String code, String message) {
        super(message);
        this.code = code;
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(Throwable cause) {
        super(cause);
    }

    public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
        super(message, cause, enableSuppression, writableStackTrace);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }
}
